<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <link rel="stylesheet" href="base.css">
</head>

<body>
    <div id='mvp'>
        <img v-bind:src="msg" width="300px" height="150px">
    </div>
    <!-- 绑定class样式 -->
    <div id='app1'>
        <div :class="appclass">绑定class样式</div>
        <div :class="[class1,class2]">数组语法</div>
    </div>
    <!-- style内联样式 -->
    <div id='app2'>
        <div :style="{'color':'blue','font-size':'20px'}">一个简单的语法</div>
        <div :style='Styleclass'>ffaf</div>
        <div :style='[aeStyle,beStyle]'>How are you</div>
    </div>

    <!-- v-if -->
    <div id='app3'>
        <p v-if="main>90">天秀</p>
        <p v-else-if='main<90 && main>=80'>独秀</p>
        <p v-else>菜秀</p>
    </div>

    <!-- v-for -->
    <div id='app4'>
        <ul>
            <template v-for="book in books">
                <li>菜名：{{book.name}}</li>
                <li>价格：{{book.price}}</li>
            </template>
        </ul>
    </div>

    <script>
        var vm = new Vue({
            el: '#mvp',
            data: {
                msg: './image/1.jpg'
            }
        })
        var app1 = new Vue({
            el: '#app1',
            data: {
                appclass: {
                    as: true,
                    bs: false
                },
                class1: 'hahd',
                class2: 'fdhife'
            }
        });

        var app2 = new Vue({
            el: '#app2',
            data: {
                Styleclass: {
                    color: 'red'
                },
                aeStyle: {
                    width: '100px',
                    height: '100px'
                },
                beStyle: {
                    background: 'coral'
                }
            }
        });
        var vm = new Vue({
            el: '#app3',
            data: {
                main: 91
            }
        });
        var app4 = new Vue({
            el: '#app4',
            data: {
                books:
                    [
                        { name: '红烧刺骨', price: '158￥', },
                        { name: '天龙非门', price: '228￥' },
                        { name: '烤鸡天歌', price: '163￥' },
                        { name: '天赐地龙', price: '335￥' },
                    ]
            },
            computed: {
                stredBooks: function () {
                    return this.books.sort(function (a, b) {
                        return b.name.length - a.name.length;
                    })
                }
            }

        })
    </script>
</body>

</html>